var getViewInfo = function () {
    // 获取手机系统信息
    let systemInfo = wx.getWindowInfo();
    console.log(systemInfo.pixelRatio);
    // 屏幕顶部状态栏高度
    let statusBarHeight = Number(systemInfo.statusBarHeight);

    // 获取胶囊区信息
    let menu = wx.getMenuButtonBoundingClientRect();

    // 胶囊区高度
    let menuHeight = menu.height;

    // 胶囊区距离屏幕顶部的距离
    let menuTop = menu.top;

    // 屏幕顶部导航栏高度
    let navBarHeight = menu.height + (menu.top - statusBarHeight) * 2;

    // 屏幕顶部状态栏加导航栏高度
    let navStatusBarHeight = statusBarHeight + menu.height + (menu.top - statusBarHeight) * 2;
    // 屏幕底部安全区高度
    // css 可用 env(safe-area-inset-bottom) 或 constant(safe-area-inset-bottom)
    let iosSABottom = 0; //
    if (systemInfo.safeArea) {
        iosSABottom = Number(systemInfo.screenHeight - systemInfo.safeArea.bottom);
    }
    let maxHeight = systemInfo.windowHeight - (navStatusBarHeight + statusBarHeight - 2);
    // console.log("获取手机系统信息", systemInfo);
    // console.log("获取胶囊区信息", menu);
    // console.log("胶囊区高度", menuHeight);
    // console.log("胶囊区距离屏幕顶部的距离", menuTop);
    // console.log("屏幕顶部状态栏高度", statusBarHeight);
    // console.log("屏幕顶部导航栏高度", navBarHeight);
    // console.log("屏幕顶部状态栏加导航栏高度", navStatusBarHeight);
    // console.log("屏幕底部安全区高度", iosSABottom);
    // console.log("最大可视化高度", maxHeight);
    return {
        iosSABottom: iosSABottom,
        maxHeight: maxHeight,
        menuWidth: menu.width,
        menuTop: menu.top+5,
        titleTopDistance: statusBarHeight - 2,
        navStatusBarHeight: navStatusBarHeight
    };
};
Component({
    ready() {
        let viewInfo = getViewInfo();
        wx.nextTick(() => {
            this.getMyView(viewInfo);
        })
    }, // 接收外部参数
    properties: {
        title: {
            type:String,
            value:"",
        },//标题
        isBack:{
            type:Boolean,
            value:true,
        },
        titleCenter:{
          type:Boolean,
          value:true,
        },
        // 是否显示标题
        isTitle:{
            type:Boolean,
            value:true,
        },
        // 是否显示右边组件
        isRight:{
            type:Boolean,
            value:false,
        },
        isFoot:{
            type:Boolean,
            value:false,
        },
        maxWidth:{
            type:Boolean,
            value:true,
        }
    }, data: {}, methods: {
        getMyView(viewInfo) {
            var that = this;
            wx.nextTick(() => {
                that.setData({
                    viewInfo: viewInfo
                })
            })
        },
        goBack(){
            var pagesArray=getCurrentPages();
            // 如果只有一个页面栈就返回首页，多个则返回上一页
            if(pagesArray.length===1){
                wx.reLaunch({
                    url:"/pages/index/index",
                });
            }else{
                wx.navigateBack()
            }
        }
    },
})
